package com.frame.interceptor

import javax.ws.rs.WebApplicationException
import javax.ws.rs.ext.WriterInterceptor
import javax.ws.rs.ext.WriterInterceptorContext
import java.util.zip.GZIPOutputStream

/**
 * Gzip输出
 *
 * Created by three on 14-7-30.
 * User: 王利平
 */
class GZIPWriterInterceptor implements WriterInterceptor {
    @Override
    void aroundWriteTo(WriterInterceptorContext context) throws IOException, WebApplicationException {
        final OutputStream outputStream = context.getOutputStream();
        context.setOutputStream(new GZIPOutputStream(outputStream));
        context.proceed();
    }
}
